<HTML><HEAD><TITLE>string_length(+String, -Length)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Strings and Atoms</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>string_length(+String, -Length)</H1>
Succeeds if Length is the length of the string String.


<DL>
<DT><EM>String</EM></DT>
<DD>String.
</DD>
<DT><EM>Length</EM></DT>
<DD>Integer or variable.
</DD>
</DL>
<H2>Description</H2>
   The length of the string String is unified with Length.

<P>
    Note that (like all predicates that return a number as their last
    argument), this predicate can be used as a function inside arithmetic
    expressions.

<H3>Modes and Determinism</H3><UL>
<LI>string_length(+, -) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>String is not instantiated (non-coroutine mode only).
<DT><EM>(5) type error </EM>
<DD>String is instantiated, but not to a string.
<DT><EM>(5) type error </EM>
<DD>Length is neither an integer nor a variable.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      string_length("Peter ",X).  (gives X=6).
      string_length("Peter ",6).
      string_length("401.35",6).

Fail:
      string_length("Peter",6).

Error:
      string_length(Str,Len).            (Error 4).
      string_length(Str,6).              (Error 4).
      string_length("small",5.0).        (Error 5).
      string_length(Str,instantiated).   (Error 5).
      string_length(Str,46.2)            (Error 5).
      string_length('this one',L).       (Error 5).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/stratom/append_strings-3.html">append_strings / 3</A>, <A HREF="../../kernel/stratom/atom_length-2.html">atom_length / 2</A>, <A HREF="../../kernel/stratom/concat_strings-3.html">concat_strings / 3</A>
</BODY></HTML>
